<html>
<head><meta charset="utf-8"><title>ResolvePathResult · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult.html">ResolvePathResult</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="223560543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult/near/223560543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult.html#223560543">(Jan 21 2021 at 19:42)</a>:</h4>
<p>We have this struct:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="p">(</span><span class="k">super</span><span class="p">)</span><span class="w"> </span><span class="k">struct</span> <span class="nc">ResolvePathResult</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="p">(</span><span class="k">super</span><span class="p">)</span><span class="w"> </span><span class="n">resolved_def</span>: <span class="nc">PerNs</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="p">(</span><span class="k">super</span><span class="p">)</span><span class="w"> </span><span class="n">segment_index</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="kt">usize</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="p">(</span><span class="k">super</span><span class="p">)</span><span class="w"> </span><span class="n">reached_fixedpoint</span>: <span class="nc">ReachedFixedPoint</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="p">(</span><span class="k">super</span><span class="p">)</span><span class="w"> </span><span class="n">krate</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="n">CrateId</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>...and I'm wondering what the fields other than <code>resolved_def</code> mean exactly. The different namespaces in <code>resolved_def</code> could come from different crates, so having only one <code>krate</code> field seems insufficient, and basically all the remaining fields also seem like they would only make sense for each individual namespace, not the whole result. What am I missing here?</p>



<a name="223573228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult/near/223573228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult.html#223573228">(Jan 21 2021 at 21:30)</a>:</h4>
<p><code>reached_fixedpoint</code> already takes into account all the namespaces, I think -- we've only reached a fixpoint if all namespaces can't change. <code>segment_index</code> is also for all namespaces because you don't resolve the path in each namespace separately -- all the intermediate results are only in the types namespace anyway</p>



<a name="223573538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult/near/223573538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult.html#223573538">(Jan 21 2021 at 21:33)</a>:</h4>
<p>as for <code>krate</code>... I don't think it's necessarily the crate that the defs originally come from</p>



<a name="223573739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult/near/223573739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult.html#223573739">(Jan 21 2021 at 21:35)</a>:</h4>
<p>I think the only use for it is to detect that if we have an import from another crate, it'll always already be fully resolved . So it doesn't really matter that it's inaccurate</p>



<a name="223573780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult/near/223573780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult.html#223573780">(Jan 21 2021 at 21:35)</a>:</h4>
<p>maybe it could be refactored to just use <code>reached_fixedpoint</code> though?</p>



<a name="223573898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult/near/223573898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult.html#223573898">(Jan 21 2021 at 21:36)</a>:</h4>
<p>I guess I'd try seeing what happens if we don't do that check</p>



<a name="223577298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult/near/223577298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/ResolvePathResult.html#223577298">(Jan 21 2021 at 22:04)</a>:</h4>
<p>I see, that makes sense</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>